#!/usr/bin/env python
"""primerpy.py, main GUI frame of primerpy-tortilla
	PrimerPy-tortilla uses primer3 as design engine.
"""


from guiclasses import *

"""
if record['run_num'] == 0:
    promote config
global_config = GlobalConf.readconf()

UserDataDir = global_config['UserDataDir']
LogFile = os.path.join(UserDataDir, global_config['LogFile'])
#ResultFile = 
#Manual=
RunID = 0


"""

class MyMainFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(520, 400))
        #-------------------------
        menu0 = wx.Menu()
        Configure = menu0.Append(-1, "Configure")
        menu0.AppendSeparator()
        Exit = menu0.Append(-1, "E&xit")
        self.Bind(wx.EVT_MENU, self.OnExit, Exit)
        # display
        menu1 = wx.Menu()
        LastRun = menu1.Append(-1, "Last Run")
        self.Bind(wx.EVT_MENU, self.OnResult, LastRun)
        Log = menu1.Append(-1, "Log")
        self.Bind(wx.EVT_MENU, self.OnLog, Log)
        menu1.AppendSeparator()
        Manual = menu1.Append(-1, "Manual")
        self.Bind(wx.EVT_MENU, self.OnManual, Manual)
        # about
        menu2 = wx.Menu()
        About = menu2.Append(-1, "About PrimerPy")
        self.Bind(wx.EVT_MENU, self.OnAbout, About)
        Boa = menu2.Append(-1, "About the boa")
        self.Bind(wx.EVT_MENU, self.OnBoa, Boa)

        menubar = wx.MenuBar()
        menubar.Append(menu0, "&PrimerPy")
        menubar.Append(menu1, "&Show")
        menubar.Append(menu2, "&About")
        self.SetMenuBar(menubar)
        #-----------------------
        
        # PrimerNoteBook, main organizer
        self.nb = PrimerNoteBook(self)
        
        self.StatusBar()
        self.Centre()
        self.Show()
        
    def StatusBar(self):
        self.statusbar = self.CreateStatusBar()
    def OnConfigure(self, event):
        pass
    def OnExit(self, event):
        self.Close(True)

    def OnResult(self, event):
        self.nb.show_result()
        self.nb.sheet_result.SetFocus()
    def OnLog(self, event):
        self.nb.show_log()
    def OnManual(self, event):
        self.nb.sheet_manual.SetFocus()


    def OnAbout(self, event):
        abox = AboutPrimerPy(self)
        abox.ShowModal()
        abox.Destroy()
    def OnBoa(self, event):
        abox = AboutBoa(self)
        abox.ShowModal()
        abox.Destroy()


#----------------------------------------------------------------------

if __name__ == '__main__':
    
    class MyApp(wx.App):
        def OnInit(self):
            frame = MyMainFrame(None, -1, 'PrimerPy, QPCR primer design')
            frame.Show(True)
            self.SetTopWindow(frame)
            return True

    app = MyApp(False)
    app.MainLoop()

